package com.four.order.service.impl;

import java.util.List;

import com.four.order.dao.OrderDao;
import com.four.order.dao.impl.OrderDaoImpl;
import com.four.order.pojo.Order;
import com.four.order.service.OrderService;

public class OrderServicelmpl implements OrderService{

	@Override
	public List<Order> selectAll() {
		OrderDao dao = new OrderDaoImpl();
		return dao.selectAll();
	}
	public boolean login(String name, String id) {
		OrderDao dao = new OrderDaoImpl();
		Order o = dao.selectByName(name);
		if(o != null && o.getName().equals(name)&&o.getId().equals(id)) {
			return true;
		}
		return false;
	}

	
	
	@Override
	public Order selectById(String id) {
		OrderDao dao = new OrderDaoImpl();
		long no = Long.valueOf(id);
		return dao.selectById(no);
	}
	
	@Override
	public boolean addOrder(String id,String name,String oaddress,String createtime,String ooldprice,String onowprice,String count,String endtime,String oflag,String oremark) {
		OrderDao dao = new OrderDaoImpl();
		int a = Integer.valueOf(name);
		long i = Long.valueOf(id);
		int n = dao.addOrder(i,a,oaddress,createtime, ooldprice, onowprice,count,endtime,oflag,oremark);
		return n>0;
	}

	@Override
	public boolean updateOrder(String id,String name,String oaddress,String createtime,String ooldprice,String onowprice,String count,String endtime,String oflag,String oremark) {
		OrderDao dao = new OrderDaoImpl();
		int a = Integer.valueOf(name);
		long i = Long.valueOf(id);
		int n = dao.updateOrder(i,a,oaddress,createtime,  ooldprice, onowprice,count,endtime,oflag,oremark);
		return n>0;
	}

	@Override
	public boolean deleteOrder(String id) {
		OrderDao dao = new OrderDaoImpl();
		long i = Long.valueOf(id);
		int n = dao.deleteOrder(i);
		return n>0;
	}
}

